package servicelocator;

import interfaces.GestionarAdministradorR;
import interfaces.GestionarUsuario;

import javax.naming.Context;
import javax.naming.InitialContext;

public class MyServiceLocator {
    
    private static String REF1 = "MiPrimerProyecto_GU#interfaces/GestionarUsuario";
    private static String REF2 = "MiPrimerProyecto-Model-GestionarAdministrador#interfaces/GestionarAdministradorR";

    public MyServiceLocator() {
        super();
    }
    
    public static  GestionarUsuario getGestionarUsuario()
        {
            Context ctx = getInitialContext();
            GestionarUsuario ref = null;
            try
            {
                ref = (GestionarUsuario)ctx.lookup(REF1);
            }catch(Exception e)
            {
                e.printStackTrace();
            }
            return ref;
        }
    
    public static  GestionarAdministradorR getGestionarAdmin()
        {
            Context ctx = getInitialContext();
            GestionarAdministradorR ref = null;
            try
            {
                ref = (GestionarAdministradorR)ctx.lookup(REF2);
            }catch(Exception e)
            {
                e.printStackTrace();
            }
            return ref;
        }
    
    private static Context getInitialContext()
        {
            Context ctx = null;
            try
            {
                ctx = new InitialContext();
            }catch(Exception e)
            {
                e.printStackTrace();
            }
            return ctx;
        }


}
